package util;

import java.util.concurrent.*;

/**
 * 线程池的创建\使用
 *
 * @see queue -阻塞队列
 *   >1AbortPolicy: 异常,方便定错 2CallerRunsPolicy(<-高并发替代品): 返回。用的不多,会出现丢失// (DiscardPolicy: 最新丢弃。DiscardOldestPolicy: 最旧丢弃。)
 *
 * @see AbstractExecutorService#submit(Callable) 的newTaskFor -提交任务包装
 *   >submit是Callable 但是任务队列是Runnable
 *
 * @author yuank
 * @date 2025/1/7
 */
class pool {
    //
    ExecutorService executorService1 = Executors.newSingleThreadExecutor();
    ExecutorService executorService2 = Executors.newCachedThreadPool();
    ExecutorService executorService3 = Executors.newFixedThreadPool(1);

    ExecutorService executorService =
            new ThreadPoolExecutor(
                    3,
                    5,
                    1, TimeUnit.SECONDS,
                    new ArrayBlockingQueue<>(5),
                    new ThreadPoolExecutor.CallerRunsPolicy()); //-> 默认拒绝策略Abort
}
